package com.qiyang.controller;

import com.qiyang.entity.User;
import com.qiyang.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created on 2020/12/16.
 *
 * @author qiyang.
 * 描述：
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("get")
    public String getUser(Model modelMap, @RequestParam(value = "id", defaultValue = "1") Long id){

        User user = userService.getUser(id);

        modelMap.addAttribute(user);

        return "viewUser";
    }

}
